package com.zhentao.controller;


import com.zhentao.common.enums.admin.AdActivity;
import com.zhentao.common.enums.dto.AdActivityDto;

import com.zhentao.dtos.ResponseResult;


import com.zhentao.dtos.Result;
import com.zhentao.service.AdActivityService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/admin/activity/v1")
public class AdActivityController {
    @Autowired
    private AdActivityService adActivityService;
//    活动列表

    @PostMapping("list")
    public ResponseResult list(@RequestBody AdActivityDto adActivityDto){
        ResponseResult acrivitylist = adActivityService.acrivitylist(adActivityDto);
        return acrivitylist;
    }


    @PostMapping("/activityList")

    public Result activityList(@RequestBody AdActivityDto adActivityDto){
        return adActivityService.activityList(adActivityDto);
    }
//增加活动
    @PostMapping("/activitySave")

    public Result activitySave(@RequestBody AdActivity adActivity){
        return adActivityService.activitySave(adActivity);
    }
//修改活动
    @PostMapping("/activityUpdate")

    public Result activityUpdate(@RequestBody AdActivity adActivity){
        return adActivityService.activityUpd(adActivity);
    }
//删除活动
    @PostMapping("/activityDelete")

    public Result activityDelete(Integer activityId){
        return adActivityService.activityDelete(activityId);
    }

//文件上传
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
        System.out.println("1111111111111111");
        return adActivityService.upload(file);
    }
}
